package com.javasm.aftersales.impl;

import com.javasm.aftersales.Repair;
import com.javasm.aftersales.RepairService;
import com.javasm.aftersales.RepairType;
import com.javasm.aftersales.dao.RepairDao;
import com.javasm.sys.tree.PosTreeUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Collection;
import java.util.List;

/**
 * @author:Dai
 * @className:RepairServiceImpl
 * @description:  维修点管理
 * @date:2022/9/23 10:40
 * @version: 1.0
 * @since: jdk11
 */
@Service
public class RepairServiceImpl  implements RepairService {
    @Autowired
    private RepairDao repairDao;

    @Override
    public List<Repair> selectAll(Repair repair) {
        List<Repair> repairs = repairDao.selectAll(repair);
        return repairs;
    }

    @Override
    public Integer insertRep(Repair repair) {
        Integer flag = repairDao.insertRep(repair);
        return flag;
    }

    @Override
    public Integer updateRep(Repair repair) {

        Integer flag = repairDao.updateRep(repair);
        return flag;
    }

    @Override
    public Integer deleteRep(Integer id) {
        Integer flag = repairDao.deleteRep(id);
        return flag;
    }

    @Override
    public Integer deleteReps(List<Integer> id) {
        Integer flag = repairDao.deleteReps(id);
        return flag;
    }

    @Override
    public List<Repair> getList(Repair repair) {
        List<Repair> list = repairDao.getList(repair);
        return list;
    }

    @Override//获取树形菜单
    public Collection<RepairType> getTree() {
        Collection<RepairType> tree = repairDao.getTree();
        List<RepairType> repairTypes = PosTreeUtil.repairTree(tree, "-1");
        return repairTypes;
    }
}
